/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.inventory.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author sithum
 */
@Entity
@Table(name = "INVOICE", catalog = "", schema = "APP")
@NamedQueries({@NamedQuery(name = "Invoice.findAll", query = "SELECT i FROM Invoice i"), @NamedQuery(name = "Invoice.findByInvoiceId", query = "SELECT i FROM Invoice i WHERE i.invoiceId = :invoiceId"), @NamedQuery(name = "Invoice.findByOrderDate", query = "SELECT i FROM Invoice i WHERE i.orderDate = :orderDate"), @NamedQuery(name = "Invoice.findByDelivaryDate", query = "SELECT i FROM Invoice i WHERE i.delivaryDate = :delivaryDate"), @NamedQuery(name = "Invoice.findByTotal", query = "SELECT i FROM Invoice i WHERE i.total = :total"), @NamedQuery(name = "Invoice.findByCustomerDiscount", query = "SELECT i FROM Invoice i WHERE i.customerDiscount = :customerDiscount"), @NamedQuery(name = "Invoice.findByNetTotal", query = "SELECT i FROM Invoice i WHERE i.netTotal = :netTotal"), @NamedQuery(name = "Invoice.findByCreatedAt", query = "SELECT i FROM Invoice i WHERE i.createdAt = :createdAt"), @NamedQuery(name = "Invoice.findByUpdatedAt", query = "SELECT i FROM Invoice i WHERE i.updatedAt = :updatedAt")})
public class Invoice implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "INVOICE_ID", nullable = false)
    private Long invoiceId;
    @Column(name = "ORDER_DATE")
    @Temporal(TemporalType.DATE)
    private Date orderDate;
    @Column(name = "DELIVARY_DATE")
    @Temporal(TemporalType.DATE)
    private Date delivaryDate;
    @Basic(optional = false)
    @Column(name = "TOTAL", nullable = false, precision = 8, scale = 2)
    private BigDecimal total;
    @Column(name = "CUSTOMER_DISCOUNT", precision = 8, scale = 2)
    private BigDecimal customerDiscount;
    @Column(name = "NET_TOTAL", precision = 8, scale = 2)
    private BigDecimal netTotal;
    @Column(name = "CREATED_AT")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdAt;
    @Column(name = "UPDATED_AT")
    @Temporal(TemporalType.TIMESTAMP)
    private Date updatedAt;
    @OneToMany(mappedBy = "invoiceId")
    private List<LineItem> lineItemCollection;
    @OneToMany(mappedBy = "invoiceId", fetch=FetchType.EAGER)
    private List<MarketReturn> marketReturnCollection;
    @OneToMany(mappedBy = "invoiceId", fetch=FetchType.EAGER)
    private List<Damaged> damagedCollection;
    @JoinColumn(name = "CUSTOMER_ID", referencedColumnName = "CUSTOMER_ID")
    @ManyToOne(fetch=FetchType.EAGER)
    private Customer customerId;
    @JoinColumn(name = "INVOICE_STATUS_ID", referencedColumnName = "INVOICE_STATUS_ID")
    @ManyToOne(fetch=FetchType.EAGER)
    private InvoiceStatus invoiceStatusId;

    public Invoice() {
    }

    public Invoice(Long invoiceId) {
        this.invoiceId = invoiceId;
    }

    public Invoice(Long invoiceId, BigDecimal total) {
        this.invoiceId = invoiceId;
        this.total = total;
    }

    public Long getInvoiceId() {
        return invoiceId;
    }

    public void setInvoiceId(Long invoiceId) {
        this.invoiceId = invoiceId;
    }

    public Date getOrderDate() {
        return orderDate;
    }

    public void setOrderDate(Date orderDate) {
        this.orderDate = orderDate;
    }

    public Date getDelivaryDate() {
        return delivaryDate;
    }

    public void setDelivaryDate(Date delivaryDate) {
        this.delivaryDate = delivaryDate;
    }

    public BigDecimal getTotal() {
        return total;
    }

    public void setTotal(BigDecimal total) {
        this.total = total;
    }

    public BigDecimal getCustomerDiscount() {
        return customerDiscount;
    }

    public void setCustomerDiscount(BigDecimal customerDiscount) {
        this.customerDiscount = customerDiscount;
    }

    public BigDecimal getNetTotal() {
        return netTotal;
    }

    public void setNetTotal(BigDecimal netTotal) {
        this.netTotal = netTotal;
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    public Date getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(Date updatedAt) {
        this.updatedAt = updatedAt;
    }

    public List<LineItem> getLineItemCollection() {
        return lineItemCollection;
    }

    public void setLineItemCollection(List<LineItem> lineItemCollection) {
        this.lineItemCollection = lineItemCollection;
    }

    public List<MarketReturn> getMarketReturnCollection() {
        return marketReturnCollection;
    }

    public void setMarketReturnCollection(List<MarketReturn> marketReturnCollection) {
        this.marketReturnCollection = marketReturnCollection;
    }

    public List<Damaged> getDamagedCollection() {
        return damagedCollection;
    }

    public void setDamagedCollection(List<Damaged> damagedCollection) {
        this.damagedCollection = damagedCollection;
    }

    public Customer getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Customer customerId) {
        this.customerId = customerId;
    }

    public InvoiceStatus getInvoiceStatusId() {
        return invoiceStatusId;
    }

    public void setInvoiceStatusId(InvoiceStatus invoiceStatusId) {
        this.invoiceStatusId = invoiceStatusId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (invoiceId != null ? invoiceId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Invoice)) {
            return false;
        }
        Invoice other = (Invoice) object;
        if ((this.invoiceId == null && other.invoiceId != null) || (this.invoiceId != null && !this.invoiceId.equals(other.invoiceId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.inventory.entities.Invoice[invoiceId=" + invoiceId + "]";
    }

}
